import threading as td
import time

def job(x,y,b):
    for i in range(x,y):
        b.write(str(i) + '\n')

def start():
    th = []
    with open(str(1) + '.txt', 'w') as book:
        for i in range(10):
            t = td.Thread(target=job, args=(10000 * i + 1, (i + 1) * 10000 + 1, book))
            t.start()
            th.append(t)
        [i.join() for i in th]


if __name__ == '__main__':
    st = time.time()
    start()
    print(time.time()-st)